package com.cms.demo.config;

import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

import java.util.Map;

/**
 * @author wangning
 * @create 2021-04-26 17:15
 */
@Component
public class MyErrorAttribute extends DefaultErrorAttributes {
	@Override
	public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
		Map<String, Object> errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace);
		errorAttributes.put("custommsg", "出错了！！！");
		errorAttributes.remove("error");
		return errorAttributes;
	}
}
